<template>
  <el-dialog
    title="详情"
    :visible.sync="dialogVisible"
    :show="show"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    append-to-body
    width="800px"
    :before-close="handleClose"
    @open="open"  
  >
    <el-form ref="form" v-loading="infoLoading" :model="info" label-width="100px">
      <el-scrollbar ref="myScrollbar" :wrap-class="{wrapClass: true}" class="form-scrollbar">
      <div class="el-dialog-div">
      <el-form-item label="产品码">
        <el-input readonly v-model="info.productCode" style="width:120px;"/>
      </el-form-item>
      <el-form-item label="标题">
        <el-input readonly v-model="info.title"/>
      </el-form-item>
      <el-form-item label="图片">
        <img v-if="info.image" :src="info.image" class="avatar"/>
      </el-form-item>
      <el-form-item label="详情">
        <el-input type="textarea" autosize v-model="info.details"/>
      </el-form-item>
      <el-form-item label="释放时间">
        <el-date-picker value-format="yyyy-MM-dd" v-model="info.releaseTime">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="到期时间">
        <el-date-picker value-format="yyyy-MM-dd" v-model="info.expireTime"/>
      </el-form-item>
      <el-form-item label="国家">
        <el-input v-model="info.country" />
      </el-form-item>
      <el-form-item label="国旗">
        <el-input v-model="info.countryFlag" />
      </el-form-item>
      <el-form-item label="链接">
        <el-input type="text" v-model="info.urlLink"/>
      </el-form-item>
      <el-form-item label="地址">
        <el-input type="text" v-model="info.address"/>
      </el-form-item>
      <el-form-item label="需求量">
        <el-input type="text" v-model="info.requireQuantity"/>
      </el-form-item>
      <el-form-item label="联系方式">
        <el-input type="text" v-model="info.contacts"/>
      </el-form-item>
      <el-form-item label="邮箱">
        <el-input type="text" v-model="info.mailbox"/>
      </el-form-item>
      <el-form-item label="微信">
        <el-input type="text" v-model="info.wechat"/>
      </el-form-item>
      <el-form-item label="电话">
        <el-input type="text" v-model="info.phone"/>
      </el-form-item>
      <el-form-item label="分类群">
        <el-input type="text" v-model="info.categoryStubs"/>
      </el-form-item>
      </div>
      </el-scrollbar>
    </el-form>
  </el-dialog>
</template>

<script>

export default {
  name: 'info',
  props: {
    show: {
      type: Boolean,
      default: false
    },
    rowData: {
      type: Object,
      // 对象或数组默认值必须从一个工厂函数获取
      default: function () {
        return {}
      }
    }
  },
  data(){
    return{
      uploadAction: '/api/Upload/UploadOemImg',
      dialogVisible: this.show,
      // 页面元素
      info: {
        
      },
      infoLoading: true,
    }
  },

  watch: {
    show() {
      this.dialogVisible = this.show
      this.initForm = true
    }
  },
  methods: {
    async open() {
      this.infoLoading = true
      // eslint-disable-next-line eqeqeq
      if (this.rowData.id) {
        this.info = this.rowData
      } else {
        this.info = {}
      }
      this.infoLoading = false
      console.log(this.show);
    },
    handleImageSuccess(res) {
        // eslint-disable-next-line eqeqeq
        if (res.code == 20000) {
          this.info.image = res.data
          this.infoLoading = false
        } else {
          this.$message.error(res.message)
          this.infoLoading = false
        }
    },   
    handleClose(done) {
      this.$emit('update:show', false)
      this.$emit('closeAction')
    }
  }
}
</script>

<style scoped>
.el-dialog__body {
  padding: 0;
}

.form-scrollbar {
  height: 500px;
}

.el-dialog-div {
  padding: 20px 20px 0 20px;
  min-width: 400px;
}

.avatar-uploader {
  width: 178px;
  height: 178px;
  border: 1px dashed #d9d9d9;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background-color: #fbfdff;
}

.avatar-uploader:hover {
  border-color: #409EFF;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}

.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>
